<?php
namespace app\controller;
use app\BaseController;
use app\model\User;
use app\Request;
use think\App;
use think\Exception;

class Index extends BaseController
{
    public function index()
    {
         return 'index';
    }
   //根据用户ID 查当前用户的信息
    public function userInfo(Request $request){
         $id=$request->param('id');
         $user=new User();
         $data=$user->getUserInfo($id);
         try{
             if(empty($data)){
                 throw new Exception('查询不到数据');
             }
         }catch (Exception $e){
             $data=$e->getMessage();
         }
         $user=[
            'code'=>200,
            'result'=>$data,
            'msg'=>'获取数据成功'
        ];
         return json($user);
    }
    //查询tp_user 表所有数据
    public function  getAlluser(){
        $alluser=new User();
        $data=$alluser->select();
        $user=[
                'code'=>200,
                'result'=>$data,
                'msg'=>'获取数据成功'
            ];
        return json($user);
    }
   //用户登录
    public  function  login(){

    }
}
